// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.characters;

import zombie.ai.states.FishingState;
import zombie.core.Core;
import zombie.iso.Vector2;
import zombie.network.GameClient;

public class NetworkPlayerVariables {
    static Vector2 deferredMovement = new Vector2();

    public static int getBooleanVariables(IsoPlayer isoPlayer) {
        int _int = 0;
        _int |= isoPlayer.isSneaking() ? 1 : 0;
        _int |= isoPlayer.isOnFire() ? 2 : 0;
        _int |= isoPlayer.isAsleep() ? 4 : 0;
        _int |= FishingState.instance().equals(isoPlayer.getCurrentState()) ? 8 : 0;
        _int |= isoPlayer.isRunning() ? 16 : 0;
        _int |= isoPlayer.isSprinting() ? 32 : 0;
        _int |= isoPlayer.isAiming() ? 64 : 0;
        _int |= isoPlayer.isCharging ? 128 : 0;
        _int |= isoPlayer.isChargingLT ? 256 : 0;
        _int |= isoPlayer.bDoShove ? 512 : 0;
        isoPlayer.getDeferredMovement(deferredMovement);
        _int |= deferredMovement.getLength() > 0.0F ? 1024 : 0;
        _int |= isoPlayer.isOnFloor() ? 2048 : 0;
        _int |= isoPlayer.isGhostMode() ? 4096 : 0;
        _int |= Core.bDebug ? 8192 : 0;
        _int |= isoPlayer.isNoClip() ? 16384 : 0;
        if (GameClient.bClient && GameClient.connection.accessLevel != 1 || !isoPlayer.isAccessLevel("None")) {
            _int |= 32768;
        }

        _int |= isoPlayer.isSitOnGround() ? 131072 : 0;
        return _int | ("fall".equals(isoPlayer.getVariableString("ClimbFenceOutcome")) ? 262144 : 0);
    }

    public static void setBooleanVariables(IsoPlayer isoPlayer, int val) {
        isoPlayer.setSneaking((val & 1) != 0);
        if ((val & 2) != 0) {
            isoPlayer.SetOnFire();
        } else {
            isoPlayer.StopBurning();
        }

        isoPlayer.setAsleep((val & 4) != 0);
        boolean _boolean = (val & 8) != 0;
        if (FishingState.instance().equals(isoPlayer.getCurrentState()) && !_boolean) {
            isoPlayer.SetVariable("FishingFinished", "true");
        }

        isoPlayer.setRunning((val & 16) != 0);
        isoPlayer.setSprinting((val & 32) != 0);
        isoPlayer.setIsAiming((val & 64) != 0);
        isoPlayer.isCharging = (val & 128) != 0;
        isoPlayer.isChargingLT = (val & 256) != 0;
        if (!isoPlayer.bDoShove && (val & 512) != 0) {
            isoPlayer.setDoShove((val & 512) != 0);
        }

        isoPlayer.networkAI.moving = (val & 1024) != 0;
        isoPlayer.setOnFloor((val & 2048) != 0);
        isoPlayer.setSitOnGround((val & 131072) != 0);
        isoPlayer.networkAI.climbFenceOutcomeFall = (val & 262144) != 0;
    }
}
